using ProduceBasicData.Domain.Entities;
using System.ComponentModel.DataAnnotations.Schema;

namespace ProduceBasicData.Api.DTO.WarehouseDto
{
    /// <summary>
    /// 库存DTO
    /// </summary>
    public class InventoryDto
    {
        /// <summary>
        /// 主键id
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 物料ID
        /// </summary>
        public int MaterialId { get; set; }  // 修正：long → int

        /// <summary>
        /// 物料编号
        /// </summary>
        public string? MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string? MaterialName { get; set; }

        /// <summary>
        /// 规格型号
        /// </summary>
        public string? Specification { get; set; }

        /// <summary>
        /// 仓库ID
        /// </summary>
        public int WarehouseId { get; set; }  // 修正：long → int

        /// <summary>
        /// 库位ID
        /// </summary>
        public int LocationId { get; set; }  // 修正：long → int

        /// <summary>
        /// 批次号
        /// </summary>
        public string? BatchNumber { get; set; }

        /// <summary>
        /// 生产日期
        /// </summary>
        public DateTime? ProductionDate { get; set; }

        /// <summary>
        /// 有效期至
        /// </summary>
        public DateTime? ExpirationDate { get; set; }

        /// <summary>
        /// 当前库存数量
        /// </summary>
        public decimal Quantity { get; set; }

        /// <summary>
        /// 锁定数量
        /// </summary>
        public decimal LockedQuantity { get; set; } = 0;

        /// <summary>
        /// 可用数量
        /// </summary>
        [NotMapped]
        public decimal AvailableQuantity => Quantity - LockedQuantity;

        /// <summary>
        /// 单位
        /// </summary>
        public string? Unit { get; set; }

        /// <summary>
        /// 库存状态 (正常、冻结、待检等)
        /// </summary>
        public string? InventoryStatus { get; set; } = "正常";  // 补充：缺少闭合的///

        /// <summary>
        /// 最后入库时间
        /// </summary>
        public DateTime? LastInTime { get; set; }

        /// <summary>
        /// 最后出库时间
        /// </summary>
        public DateTime? LastOutTime { get; set; }
    }
}